package com.chang.untils;

/**
 * @program: erp-api
 * @description:
 * @author: chang
 * @create: 2025-02-25 20h
 **/

import java.util.Map;

/**
 * 线程局部变量
 */
public class ThreadLocalUtils {
    static  ThreadLocalUtils instance;
    /**
     * 线程局部变量
     */
    ThreadLocal<Map> threadLocal=new ThreadLocal<>();

    /**
     * 保存数据
     * @param map
     */
    public void set(Map map){
        threadLocal.set(map);
    }

    public Map get(){
        return threadLocal.get();
    }

    private ThreadLocalUtils(){
    }

    public static ThreadLocalUtils getInstance(){
        if(instance==null){
            instance=new ThreadLocalUtils();
        }
        return instance;
    }
}
